home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Small Eiffel 0.4.8 / lib_std / platform.e < prev    next >
Encoding:
Text File  |  1997-04-13  |  2.7 KB  |  128 lines  |  [TEXT/ttxt]

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. class PLATFORM
  5.  
  6. inherit GENERAL;
  7.    
  8. feature -- Maximum :
  9.  
  10.     Maximum_character_code : INTEGER is
  11.      -- Largest supported code for CHARACTER values.
  12.       once
  13.      c_inline_c("R=CHAR_MAX;");
  14.       ensure
  15.      meaningful: Result >= 127
  16.       end;
  17.  
  18.     Maximum_integer: INTEGER is
  19.       -- Largest supported value of type INTEGER.
  20.       once
  21.      c_inline_c("R=INT_MAX;");
  22.       ensure
  23.      meaningful: Result >= 0
  24.       end;
  25.  
  26.     Maximum_real: REAL is
  27.       -- Largest supported value of type REAL.
  28.       once
  29.      c_inline_c("R=FLT_MAX;");
  30.       ensure
  31.      meaningful: Result >= 0.0
  32.       end;
  33.  
  34.     Maximum_double: DOUBLE is
  35.       -- Largest supported value of type DOUBLE.
  36.       once
  37.      c_inline_c("R=DBL_MAX;");
  38.       ensure
  39.      meaningful: Result >= 0.0
  40.       end;
  41.  
  42. feature -- Minimum :
  43.  
  44.    Minimum_character_code: INTEGER is
  45.       -- Smallest supported code for CHARACTER values.
  46.       once
  47.      c_inline_c("R=CHAR_MIN;");
  48.       ensure
  49.      meaningful: Result <= 0
  50.       end;
  51.  
  52.    Minimum_integer: INTEGER is
  53.       -- Smallest supported value of type INTEGER.
  54.       once
  55.      c_inline_c("R=INT_MIN;");
  56.       ensure
  57.      meaningful: Result <= 0
  58.       end;
  59.  
  60.    Minimum_double: DOUBLE is
  61.       -- Smallest supported value of type DOUBLE.
  62.       once
  63.      Result := - Maximum_double;
  64.       ensure
  65.      meaningful: Result <= 0
  66.       end;
  67.  
  68.    Minimum_real: REAL is
  69.       -- Smallest supported value of type REAL.
  70.       once
  71.      Result := - Maximum_real;
  72.       ensure
  73.      meaningful: Result <= 0
  74.       end;
  75.  
  76. feature -- Bits :
  77.  
  78.    Boolean_bits: INTEGER is
  79.       -- Number of bits in a value of type BOOLEAN.
  80.       once
  81.      Result := Character_bits * (true).object_size;
  82.       ensure
  83.      meaningful: Result >= 1
  84.       end;
  85.  
  86.    Character_bits: INTEGER is
  87.       -- Number of bits in a value of type CHARACTER.
  88.       external "CSE"
  89.       ensure
  90.      meaningful: Result >= 1;
  91.      large_enough: (2^Result) >= Maximum_character_code;
  92.       end;
  93.  
  94.    Integer_bits: INTEGER is
  95.      -- Number of bits in a value of type INTEGER.
  96.       external "CSE"
  97.       ensure
  98.      meaningful: Result >= 1;
  99.       end;
  100.    
  101.    Real_bits: INTEGER is
  102.      -- Number of bits in a value of type DOUBLE.
  103.       once
  104.      Result := Character_bits * (1.5).object_size;
  105.       ensure
  106.      meaningful: Result >= 1;
  107.      meaningful: Result >= Real_bits;
  108.       end;
  109.  
  110.    Double_bits: INTEGER is
  111.      -- Number of bits in a value of type DOUBLE.
  112.       once
  113.      Result := Character_bits * (1.5).to_double.object_size;
  114.       ensure
  115.      meaningful: Result >= 1;
  116.      meaningful: Result >= Real_bits;
  117.       end;
  118.  
  119.    Pointer_bits: INTEGER is
  120.      -- Number of bits in a value of type REAL.
  121.       local
  122.      p: POINTER;
  123.       once
  124.      Result := Character_bits * p.object_size;
  125.       end;
  126.  
  127. end -- PLATFORM
  128.